import Request from "@/sdk/pocky-request/index.js"; //引入
import CFG from "@/common/config.js";
/**
 * shopStore 店铺模块
 */
const shop = {
	// 状态
	state: {

	},
	// 内部派生
	getters: {

	},
	// 同步方法 commit
	mutations: {

	},
	// 异步方法 dispatch
	actions: {
		/**
		 * @description 获取店铺详情
		 * @param {Object} context
		 * @param {Object} _id
		 */
		apiGetShopDetail(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/store/detail.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						uni.showToast({
							title: '获取店铺详情失败,' + res.data.msg,
							icon: 'none'
						});
						reject(res)
					}
				}).catch(err => {
					uni.showToast({
						title: JSON.stringify(err),
						icon: 'none'
					});
				})
			})
		},
		/**
		 * @description 根据教师ID获取教师详情
		 * @param {Object} context
		 * @param {Object} _id
		 */
		apiGetTeacherDtById(context, _id) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '',
					method: 'post',
					data: {
						id: _id
					}
				}).then(res => {
					if (res.data.code == 1) {

					} else {
						uni.showToast({
							title: '获取教师详情失败,' + res.data.msg,
							icon: 'none'
						});
					}
				}).catch(err => {
					uni.showToast({
						title: JSON.stringify(err),
						icon: 'none'
					});
				})
			})
		},
		/**
		 * 获取活动列表
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetGroupList(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/course/list.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)

					} else {
						// uni.showToast({
						// 	title: '添加店铺失败,'+res.data.msg,
						// 	icon: 'none'
						// });
					}
				})

			})
		},
		/**
		 * @description 获取活动详情
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetGroupDetail(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					// url: '/group/course/detail.do',
					url:CFG.apiUrl+'training-server/activity/detail.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)

					} else {
						// uni.showToast({
						// 	title: '添加店铺失败,'+res.data.msg,
						// 	icon: 'none'
						// });
					}
				})

			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 获取拼团活动详情
		 */
		apiGetGroupDetailpt(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/course/detail.do',
					// url:CFG.apiUrl+'training-server/activity/detail.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
		
					} else {
						// uni.showToast({
						// 	title: '添加店铺失败,'+res.data.msg,
						// 	icon: 'none'
						// });
					}
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 好课拼购的详情
		 */
		spellGroupDetails(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/spell/spellGroupDetails.do',
					// url:CFG.apiUrl+'training-server/activity/detail.do',
					method: 'post',
					data: _data
				}).then(res => {
					resolve(res)
		// 			if (res.data.code == 1) {
						
		
		// 			} else {
		// 				// uni.showToast({
		// 				// 	title: '添加店铺失败,'+res.data.msg,
		// 				// 	icon: 'none'
		// 				// });
		// 			}
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 获取好课拼购的详情展示的拼团
		 */
		showSpellList(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/spell/showSpellList.do',					
					method: 'GET',
					data: _data
				}).then(res => {
					resolve(res)		
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data  获取订单状态的值
		 */
		
		apiGetListStatus(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/course/getOrder.do',
					// url:CFG.apiUrl+'training-server/activity/detail.do',
					method: 'GET',
					data: _data
				}).then(res => {
					resolve(res)
					
				})
		
			})
		},
		/**
		 * @description  开团
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiOpenGroup(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/open.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)

					} else {
						uni.showToast({
							title: '开团失败,' + res.data.msg,
							icon: 'none'
						});
					}
				})

			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 好课拼购开团
		 */
		openSpellGroup(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/spell/openSpellGroup.do',
					method: 'post',
					data: _data
				}).then(res => {
					
					resolve(res)
		// 			if (res.data.code == 1) {
						
		
		// 			} else {
		// 				uni.showToast({
		// 					title: '开团失败,' + res.data.msg,
		// 					icon: 'none'
		// 				});
		// 			}
				})
		
			})
		},
		/**
		 * @description 获取我的拼团列表
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetMyGroupList(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/list.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)

					} else {
						uni.showToast({
							title: '获取拼团失败,' + res.data.msg,
							icon: 'none'
						});
						resolve([])
					}
				})

			})
		},
		/**
		 * @description 获取我的拼团详情
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetMyGroupDt(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/detail.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						uni.showToast({
							title: '获取拼团详情失败,' + res.data.msg,
							icon: 'none'
						});
						resolve([])
					}
				})

			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 好课拼购拼团详情
		 */
		newdetail(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/spell/detail.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						uni.showToast({
							title: '获取拼团详情失败,' + res.data.msg,
							icon: 'none'
						});
						resolve([])
					}
				})
		
			})
		},
		
		/** 获取拼团返回的状态
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetMyorderStatus(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/mall/updateCourseGroupStatus.do',
					method: 'GET',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						// uni.showToast({
						// 	title: '获取拼团详情失败,' + res.data.msg,
						// 	icon: 'none'
						// });
						resolve(res)
					}
				})
		
			})
		},
		
	
		//拼团返现
		apiGetMyorderYongjin(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/pay/ali/payreturnBrokerage.do',
					method: 'GET',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						
						resolve(res)
					}
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 发起助力
		 */
		apiOpenApower(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/Apower.do',
					method: 'post',
					data: _data
				}).then(res => {
					console.log(res)
					if (res.data.result == 1) {
						resolve(res)
		
					} else {
						uni.showToast({
							title: '助力失败,' + res.data.msg,
							icon: 'none'
						});
					}
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 获取助力好友的列表
		 */
		apiOpenApowerlist(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/cutPriceLog.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		
		/**
		 * @param {Object} context
		 * @param {Object} _data 助力活动入口
		 */
		apihomePagePower(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/homePagePower.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		
		/**
		 * @param {Object} context
		 * @param {Object} _data 好友助力
		 */
		apiOpenApowerFriend(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/buddiesPower.do',
					method: 'POST',
					data: _data
				}).then(res => {
					    resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data获取PowerInId的接口
		 */
		apiOpenGetPowerInId(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/getPowerInId.do',
					method: 'GET',
					data: _data
				}).then(res => {
					    resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 
		 * 获取我的助力活动
		 * 
		 */
		apiGetMypowerlists(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/myPowerCourse.do',
					method: 'GET',
					data: _data
				}).then(res => {
					
					resolve(res)
					// console.log(res)
				
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data  更新助力活动状态
		 */
		apiGetpowerstatus(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/updatePowerType.do',
					method: 'POST',
					data: _data
				}).then(res => {
					
					resolve(res)
					// console.log(res)
				
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 获取助力活动的状态
		 */
		getstatuspowerid(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/getPowerType.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data
		 * 获取助力轮播的接口
		 */
		apiGetpowersuccess(context) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/successMessage.do',
					method: 'GET'
				
				}).then(res => {
					
					resolve(res)
					// console.log(res)
				
				})
		
			})
		},
		apiOpenApowerlog(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/group/powerLog.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 领取老带新福利
		 */
		apiOpenold(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/oldAndNew/getOldAndNewWelfare.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data
		 *  判断店铺是否有老带新的活动
		 */
		apiyesold(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/oldAndNew/getStoreOldAndNewWelfare.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 老带新的详情
		 */
		apiyesoldxiangqing(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/oldAndNew/oldAndNewWelfarePage.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 分享页面的详情
		 */
		apiyesonlynewxiangqing(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/oldAndNew/actoldAndNewInFo.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 老带新的分享统计
		 */
		apioldsharetongji(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/oldAndNew/share.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 新学员领取福利
		 */
		apioldnewstudent(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/oldAndNew/getNewStudentCard.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 我的福利列表
		 */
		apimyoldnewstudent(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/oldAndNew/myWelfareCard.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 我的福利详情新的老的
		 */
		apiwelfarePage(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/oldAndNew/welfarePage.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 店铺常规活动首页展示
		 */
		showStoreUsual(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/usual/showStoreUsual.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 常规活动详情
		 */
		usualDetails(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/usual/usualDetails.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 常规活动的统计
		 */
		statisticsHeat(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/usual/statisticsHeat.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 常规活动报名生成订单
		 */
		enterFor(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/usual/enterFor.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 我的常规活动列表
		 */
		myEnterFor(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/usual/myEnterFor.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 好课拼购店铺首页入口
		 */
		showStoreSpell(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/spell/showStoreSpell.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		/**
		 * @param {Object} context
		 * @param {Object} _data 好课拼购分享浏览统计
		 */
		NEWstatisticsHeat(context, _data) {
			return new Promise(resolve => {
				let r = Request();
				r.request({
					url: '/spell/statisticsHeat.do',
					method: 'GET',
					data: _data
				}).then(res => {
					// console.log(res)
					resolve(res)
				})
		
			})
		},
		
		/**
		 * 关注店铺
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiFollowShop(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/store/fav.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.result == 1) {
						resolve(res)
					} else {
						reject(res);
					}
				}).catch(err => {
					reject(res)
				})
			})
		},
		/**
		 * @description 生成口令
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetPass(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/group/genToken.do',
					method: 'post',
					data: _data
				}).then(res => {
					
					if (res.data.code == 1) {
						resolve(res)
					} else {
						reject(res);
					}
				}).catch(err => {

					reject(res)
				})
			})
		},
		// (#.*?#)

		/**
		 * 解析口令
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiResolvePass(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/group/getToken.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						reject(res);
					}
				}).catch(err => {

					reject(res)
				})
			})
		},
		/**
		 * @description  获取团长奖励
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetCmdRew(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/group/award/list.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						reject(res);
					}
				}).catch(err => {

					reject(res)
				})
			})
		},
		/**
		 * 获取拼团返现
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetGroupReturn(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/group/refund/list.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						reject(res);
					}
				}).catch(err => {

					reject(res)
				})
			})
		},
		/**获取提现记录
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetTxHis(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/group/fetch/list.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						reject(res);
					}
				}).catch(err => {

					reject(res)
				})
			})
		},
		/**
		 * @description 获取零元购活动列表
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetZeroList(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/zero/course/list.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						reject(res);
					}
				}).catch(err => {

					reject(res)
				})
			})
		},
		/**
		 * @description 获取零元购活动详情
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetZeroDetail(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/zero/course/detail.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						reject(res);
					}
				}).catch(err => {

					reject(res)
				})
			})
		},
		/**
		 * @description 提交零元购订单
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiPostZeroOrder(context, _data) {
			return new Promise((resolve, reject) => {
				Request().request({
					url: '/mall/order.do',
					method: 'post',
					data: _data
				}).then(res => {
					if (res.data.code == 1) {
						resolve(res)
					} else {
						reject(res);
					}
				}).catch(err => {

					reject(res)
				})
			})
		}
	}
}

export default shop
